﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace FourKill.Engine
{
    public class SpriteSheet9By8 : BaseSpriteSheet
    {
        private const int X_STEP_LEFT_FOOT = 0, X_STILL = 1, X_STEP_RIGHT_FOOT = 2;
        private const int Y_FORWARD = 0, Y_LEFT = 1, Y_RIGHT = 2, Y_BACK = 3;


        public SpriteSheet9By8(Bitmap sheetImage, int columns, int rows)
            : base(sheetImage, columns, rows) {}

        public SpriteSheet9By8(Bitmap sheetImage, int columns, int rows, Color transparentColor)
            : base(sheetImage, columns, rows, transparentColor) { }

        public override int GetFrameCount(SpriteState state)
        {
            return state == SpriteState.StandingStill ? 1 :  8;
        }

        public override int BottomClip
        {
            get { return 5; }
        }

        public override Bitmap GetImage(double angle, int index, SpriteState state)
        {
            Bitmap bmp = null;
            index = (state == SpriteState.StandingStill || state == SpriteState.FloatingStill) ? 8 : index;
            SpriteDirection dir = Determine8WayDirection(angle);
            switch (dir)
            {
                case SpriteDirection.Left:
                    bmp = this[index, 0];
                    break;
                case SpriteDirection.LeftBack:
                    bmp = this[index, 1];
                    break;
                case SpriteDirection.Back:
                    bmp = this[index, 2];
                    break;
                case SpriteDirection.RightBack:
                    bmp = this[index, 3];
                    break;
                case SpriteDirection.Right:
                    bmp = this[index, 4];
                    break;
                case SpriteDirection.RightFront:
                    bmp = this[index, 5];
                    break;
                case SpriteDirection.Front:
                    bmp = this[index, 6];
                    break;
                case SpriteDirection.LeftFront:
                default:
                    bmp = this[index, 7];
                    break;
            }
            return bmp;
        }
    }
}
